package com.atguigu.tingshu.user.factory.impl;

import com.atguigu.tingshu.user.factory.StrategyFactory;
import com.atguigu.tingshu.user.strategy.ItemTypeStrategy;
import com.atguigu.tingshu.user.strategy.impl.AlbumStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author atguigu-mqx
 * @ClassName StrategyFactoryImpl
 * @description: TODO
 * @date 2025年03月10日
 * @version: 1.0
 */
@Service
public class StrategyFactoryImpl implements StrategyFactory {

    @Autowired
    private Map<String, ItemTypeStrategy> strategyMap;
    @Override
    public ItemTypeStrategy getStrategy(String itemType) {
        //  判断itemType 是否为空;
        if (strategyMap.containsKey(itemType)){
            //  根据key来获取不同的实现类
            return strategyMap.get(itemType);
        }
        //  默认返回
        return null;
    }
}
